/**
 * 
 */
package eu.news.data.hibernate.dao;

import java.util.Collection;

import org.hibernate.Query;

import eu.news.data.dao.SysConfigDAO;
import eu.news.data.hibernate.pojo.HB_SysConfig;
import eu.news.data.pojo.SysConfig;


/**
 * @author WZZ
 *
 */
public class HB_SysConfigDAO extends HibernateBaseDAO<SysConfig> implements SysConfigDAO {
	
	protected HB_SysConfigDAO(){}
	
	public SysConfig getByKey(String key){
		String hql="from HB_SysConfig where key=:key";
		Query query=session.createQuery(hql);
		query.setString("key", key);
		return (SysConfig) query.uniqueResult();
	}
	
	@SuppressWarnings("unchecked")
	public Collection<SysConfig> getAll(int start,int size){
		String hql="from HB_SysConfig";
		Query query=session.createQuery(hql);
		query.setFirstResult(start);
		query.setMaxResults(size);
		return query.list();
	}

	@Override
	public SysConfig newEntity() {
		return new HB_SysConfig();
	}
}
